Using a Unicode format for Python's `time.strftime()`

Posted by Hosam Aly on Stack Overflow See other posts from Stack Overflow or by Hosam Aly
Published on 2010-04-03T14:35:31Z Indexed on 2010/04/03 14:43 UTC
Read the original article Hit count: 567

Filed under:
|

I am trying to call Python's time.strftime() function using a Unicode format string:

u'%d\u200f/%m\u200f/%Y %H:%M:%S'

(\u200f is the "Right-To-Left Mark" (RLM).)

However, I am getting an exception that the RLM character cannot be encoded into ascii:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u200f' in position 2: ordinal not in range(128)

I have tried searching for an alternative but could not find a reasonable one. Is there an alternative to this function, or a way to make it work with Unicode characters?

© Stack Overflow or respective owner

Related posts about python

Related posts about unicode